fix some format mismatches found by PVS-Studio
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Wed, 24 Mar 2021 14:16:24 +0000 (08:16 -0600)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Wed, 24 Mar 2021 14:16:24 +0000 (08:16 -0600)
V576 Incorrect format. Consider checking the second actual argument of the 'asprintf' function. The SIGNED integer type argument is expected.

QString::asprintf is not recommended for new code anyway.

mtk_logger.cc
skytraq.cc
waypt.cc

index 0c8bb9d76c0da7c4f795fd19756c7c26270f0d86..6a36421bc89eaf24c20a5c60a36f535111eab33d 100644 (file)
@@ -901,7 +901,7 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm)
     /* Button press -- create waypoint, start count at 1 */
     auto* w = new Waypoint(*trk);
 
-    w->shortname = QString::asprintf("WP%06d", waypt_count()+1);
+    w->shortname = QString("WP%1").arg(waypt_count() + 1, 6, 10, QLatin1Char('0'));
     waypt_add(w);
   }
   // In theory we would not add the waypoint to the list of
index 06be955caae67d62c7a2c02791d8860724216d03..b0c7b2eda020bd2a1bfb3622e2c23d3126708a97 100644 (file)
@@ -696,7 +696,7 @@ make_trackpoint(struct read_state* st, double lat, double lon, double alt)
 {
   auto* wpt = new Waypoint;
 
-  wpt->shortname = QString::asprintf("TP%04d", ++st->tpn);
+  wpt->shortname = QString("TP%1").arg(++st->tpn, 4, 10, QLatin1Char('0'));
 
   wpt->latitude       = lat;
   wpt->longitude      = lon;
index 6cbd1c24f1e89e52f36850de921682bd638d2252..e8f72709a1da87dc34ddbff4c58b28879f18c8b9 100644 (file)
--- a/waypt.cc
+++ b/waypt.cc
@@ -617,7 +617,7 @@ WaypointList::waypt_add(Waypoint* wpt)
     } else if (!wpt->notes.isNull()) {
       wpt->shortname = wpt->notes;
     } else {
-      wpt->shortname = QString::asprintf("WPT%03d", waypt_count());
+      wpt->shortname = QString("WPT%1").arg(waypt_count(), 3, 10, QLatin1Char('0'));
     }
   }